home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Audio
/
Patchmix
/
XWindowsSource
/
tree.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-28
|
2KB
|
81 lines
static char rcsid[] = "$Header: tree.c,v 1.1 90/08/27 17:09:44 mara Exp $";
/*
* tree.c
*
* Written by Mara Helmuth
*
* Description: Tree classes for Cmix X graphical interface
*
* $Log: tree.c,v $
* Revision 1.1 90/08/27 17:09:44 mara
* Initial revision
*
* Revision 1.3 90/05/13 15:44:09 mara
* *** empty log message ***
*
* Revision 1.2 90/03/01 20:08:47 mara
* Calls intrument::process_ugen
* Constructor inserts all.
*
*/
#include "plus.h"
ugen_tree::ugen_tree(int s, int out_ugen, getinputtype l, getinputtype r)
{
root = 0;
size = s;
get_left = l;
get_right = r;
root = new s_node;
root->left = root->right = 0;
root->contents = out_ugen;
insert(root);
}
void ugen_tree::insert(s_node* parent)
{
s_node* left_node = new s_node;
left_node->contents = get_left(parent->contents);
left_node->left = left_node->right = 0;
parent->left = left_node;
if(left_node->contents > 0)
insert(left_node);
else
printf("beginning of branch\n");
s_node* right_node = new s_node;
right_node->contents = get_right(parent->contents);
right_node->left = right_node->right = 0;
parent->right = right_node;
if(right_node->contents > 0) {
printf("getting last (right) branch of ugen %d\n",parent->contents);
insert(right_node);
}
else
printf("beginning of branch\n");
printf("now do ugen %d\n",parent->contents);
inst.instrument::process_ugen(parent->contents, parent->left->contents, parent->right->contents);
}
void ugen_tree::clear(s_node* n,int first)
{
s_node* current;
if (first) {
current = root;
first = 0;
root = 0;
}
else
current = n;
if (current != 0) {
clear(current -> left,first);
clear(current -> right,first);
if (current) {
delete current;
}
}
}